// Package handler
// Title  		user.handler.go
// Description  ClusterHandler协调适配器
// Author  alittlexincan@163.com  2024/07/22 11:36
// Update  alittlexincan@163.com  2024/07/22 11:36
package handler

import (
	"github.com/go-kit/kit/transport/http"
	"xincan.com.cn/tarot-go/internal/app/tarot/user/endpoint"
	"xincan.com.cn/tarot-go/internal/app/tarot/user/service"
	"xincan.com.cn/tarot-go/internal/app/tarot/user/transport"
	"xincan.com.cn/tarot-go/internal/common/response"
	"xincan.com.cn/tarot-go/internal/components/middleware"
)

// CreateUserHandler
// Title    		CreateUserHandler
// Description   	创建用户
// Author      		alittlexincan@163.com         	2024/07/22 11:36
// Return    		*http.Server    				创建用户
func CreateUserHandler() *http.Server {
	svc := service.NewUserService()
	ep := endpoint.MakeCreateUserEndpoint(svc)
	return http.NewServer(ep, transport.DecodeCreateUserRequest, response.EncodeResponse)
}

// SearchUserListHandler
// Title    		SearchUserListHandler
// Description   	查询集群节点信息统计
// Author      		alittlexincan@163.com         	2024/07/22 11:36
// Return    		*http.Server    				查询集群节点信息
func SearchUserListHandler() *http.Server {
	// 1: 创建服务
	svc := service.NewUserService()
	// 2: 创建基础endpoint
	ep := endpoint.MakeSearchUserListEndpoint(svc)
	// 3: 链式调用: 验证参数
	ep = middleware.ValidationObjectMiddleware()(ep)
	//options := []http.ServerOption{
	//	http.ServerErrorEncoder(response.CustomErrorEncoder),
	//}
	//return http.NewServer(ep, transport.DecodeSearchUserListRequest, response.EncodeResponse, options...)
	return http.NewServer(ep, transport.DecodeSearchUserListRequest, response.EncodeResponse)
}
